package com.tencent.matrix.g;

import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;

import java.util.HashSet;
import java.util.Iterator;

public class Matrix_G_B {
    private static volatile HandlerThread cHt;
    private static volatile Handler cHu;
    private static volatile Handler cHv = new Handler(Looper.getMainLooper());
    private static HashSet<HandlerThread> cHw = new HashSet<>();
    public static boolean cml = false;

    public static HandlerThread dT(String str) {
        Iterator it = cHw.iterator();
        while (it.hasNext()) {
            if (!((HandlerThread) it.next()).isAlive()) {
                it.remove();
                Matrix_G_C.w("Matrix.HandlerThread", "warning: remove dead handler thread with name %s", str);
            }
        }
        HandlerThread handlerThread = new HandlerThread(str);
        handlerThread.start();
        cHw.add(handlerThread);
        Matrix_G_C.w("Matrix.HandlerThread", "warning: create new handler thread with name %s, alive thread size:%d", str, cHw.size());
        return handlerThread;
    }
}
